home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
tm.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
27KB
|
1,140 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATKeyboard Version 3.0 ** */
/* ** Copright (C) 1992-1993 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ** Tastaturtabellen-Editor ** */
/* ** ** */
/* ******************************************************************* */
#include "ATKeyboard.h"
EXTERN LONG KickstartVersion;
EXTERN UBYTE TastenTabelle[256];
extern struct TextAttr OpalFontDef;
extern struct IntuiText Trennlinie_Text;
extern struct IntuiText Wirklich_Text;
extern struct Einstellungen Einstellungen;
extern struct KeyCodes *KeyCodes;
extern struct FileRequester *FileRequester;
extern struct MenuItem TM_Item[];
struct KeyTab *BackupKeys;
struct IntuiText TU_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Rücknahme aller Aktionen",
};
struct IntuiText Kopieren_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Taste kopieren",
};
struct IntuiText Tauschen_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Tasten tauschen",
};
struct IntuiText CodeTable_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"CodeTable-Datei",
};
struct IntuiText Translator_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Translator-Datei",
};
struct IntuiText ML_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Tastaturtabelle laden von",
};
struct IntuiText MS_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Tastaturtabelle sichern als",
};
struct IntuiText TE_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Übernehmen und Beenden",
};
struct MenuItem TE_Item=
{
NULL,
5,30,300,10,
HIGHIMAGE|ITEMENABLED|ITEMTEXT|COMMSEQ,
0L,
&TE_Text,
&Wirklich_Text,
'Q',NULL
};
struct MenuItem Trennlinie02_Item=
{
&TE_Item,
5,20,300,10,
HIGHNONE|ITEMTEXT,
0L,
&Trennlinie_Text,
NULL,
0,NULL
};
struct MenuItem CS_Item=
{
NULL,
180,14,250,10,
HIGHCOMP|ITEMENABLED|COMMSEQ|ITEMTEXT,
0L,
&CodeTable_Text,
NULL,
'R',NULL
};
struct MenuItem TS_Item=
{
&CS_Item,
180,4,250,10,
HIGHCOMP|ITEMENABLED|COMMSEQ|ITEMTEXT,
0L,
&Translator_Text,
NULL,
'S',NULL
};
struct MenuItem CL_Item=
{
NULL,
180,14,250,10,
HIGHCOMP|ITEMENABLED|COMMSEQ|ITEMTEXT,
0L,
&CodeTable_Text,
NULL,
'W',NULL
};
struct MenuItem TL_Item=
{
&CL_Item,
180,4,250,10,
HIGHCOMP|ITEMENABLED|COMMSEQ|ITEMTEXT,
0L,
&Translator_Text,
NULL,
'L',NULL
};
struct MenuItem MS_Item=
{
&Trennlinie02_Item,
5,10,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT,
0L,
&MS_Text,
NULL,
0,&TS_Item
};
struct MenuItem ML_Item=
{
&MS_Item,
5,0,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT,
0L,
&ML_Text,
NULL,
0,&TL_Item
};
struct MenuItem Swap_Item=
{
NULL,
5,20,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT|COMMSEQ,
0L,
&Tauschen_Text,
NULL,
'T',NULL
};
struct MenuItem Copy_Item=
{
&Swap_Item,
5,10,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT|COMMSEQ,
0L,
&Kopieren_Text,
NULL,
'C',NULL
};
struct MenuItem TU_Item=
{
&Copy_Item,
5,0,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT|COMMSEQ,
0L,
&TU_Text,
NULL,
'X',NULL
};
struct Menu TBearbeiten_Menu=
{
NULL,
140,0,130,10,
MENUENABLED,
"Bearbeiten",
&TU_Item
};
struct Menu TDatei_Menu=
{
&TBearbeiten_Menu,
5,0,130,10,
MENUENABLED,
"Datei",
&ML_Item
};
#define MENU_DATEI 0
#define ITEM_LADEN 0
#define ITEM_SICHERN 1
#define SUBITEM_TRANSLATOR 0
#define SUBITEM_CODETABLE 1
#define ITEM_ENDE 3
#define MENU_BEARBEITEN 1
#define ITEM_UNDO 0
#define ITEM_KOPIEREN 1
#define ITEM_TAUSCHEN 2
#define xITEMENABLED (0xffff-ITEMENABLED)
struct Image PImage;
struct PropInfo PInfo=
{
AUTOKNOB|FREEVERT|PROPBORDERLESS,0,0,0,512
};
struct Gadget Prop_Gadget=
{
NULL,
365,40,68,80,
GADGHCOMP,
RELVERIFY,
PROPGADGET,
&PImage,NULL,NULL,
NULL,&PInfo,500,NULL
};
UBYTE ST[8][40];
struct IntuiText Select_Text[8]=
{
{2,0,AUTODRAWMODE,12,1,&OpalFontDef,&ST[0],NULL},
{2,0,AUTODRAWMODE,12,1,&OpalFontDef,&ST[1],NULL},
{2,0,AUTODRAWMODE,12,1,&OpalFontDef,&ST[2],NULL},
{2,0,AUTODRAWMODE,12,1,NULL,&ST[3],NULL},
{2,0,AUTODRAWMODE,12,1,NULL,&ST[4],NULL},
{2,0,AUTODRAWMODE,12,1,NULL,&ST[5],NULL},
{2,0,AUTODRAWMODE,12,1,NULL,&ST[6],NULL},
{2,0,AUTODRAWMODE,12,1,NULL,&ST[7],NULL}
};
struct Gadget Select_Gadget[8]=
{
{
&Select_Gadget[1],
10,40,340,10,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,&Select_Text[0],
NULL,NULL,0,NULL
},
{
&Select_Gadget[2],
10,50,340,10,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,&Select_Text[1],
NULL,NULL,1,NULL
},
{
&Select_Gadget[3],
10,60,340,10,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,&Select_Text[2],
NULL,NULL,2,NULL
},
{
&Select_Gadget[4],
10,70,340,10,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,&Select_Text[3],
NULL,NULL,3,NULL
},
{
&Select_Gadget[5],
10,80,340,10,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,&Select_Text[4],
NULL,NULL,4,NULL
},
{
&Select_Gadget[6],
10,90,340,10,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,&Select_Text[5],
NULL,NULL,5,NULL
},
{
&Select_Gadget[7],
10,100,340,10,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,&Select_Text[6],
NULL,NULL,6,NULL
},
{
&Prop_Gadget,
10,110,340,10,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,&Select_Text[7],
NULL,NULL,7,NULL
}
};
struct Gadget Swap_Gadget=
{
&Select_Gadget[0],
240,12,81,11,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,NULL,
NULL,NULL,3000,NULL
};
struct Gadget Copy_Gadget=
{
&Swap_Gadget,
150,12,81,11,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,NULL,
NULL,NULL,2000,NULL
};
struct Gadget Test_Gadget=
{
&Copy_Gadget,
10,12,81,11,
GADGHCOMP,
RELVERIFY,
BOOLGADGET,
NULL,NULL,NULL,
NULL,NULL,1000,NULL
};
struct NewWindow TMWindow=
{
75,25,450,128,
0,1,
GADGETUP|CLOSEWINDOW|VANILLAKEY|MENUPICK,
WINDOWDEPTH|WINDOWDRAG|WINDOWCLOSE|ACTIVATE,
&Test_Gadget,NULL,"ATKeyboard - Tastaturtabellen Editor",
NULL,NULL,
450,128,450,128,
WBENCHSCREEN
};
UBYTE Name[20];
struct InputEvent ie=
{
NULL,IECLASS_RAWKEY,0,0,0
};
struct RawName
{
WORD Select;
UBYTE *Name;
};
struct RawName RawName[]={
0x45,"Escape",
0x50,"F1",
0x51,"F2",
0x52,"F3",
0x53,"F4",
0x54,"F5",
0x55,"F6",
0x56,"F7",
0x57,"F8",
0x58,"F9",
0x59,"F10",
0x46,"Del",
0x5f,"Help",
0x41,"Backspace",
0x66,"Amiga links",
0x67,"Amiga rechts",
0x64,"Alt links",
0x65,"Alt rechts",
0x60,"Shift links",
0x61,"Shift rechts",
0x63,"Control",
0x62,"Caps Lock",
0x40,"Space",
0x42,"Tab",
0x44,"Return",
0x43,"Enter",
0x4c,"Cursor auf",
0x4f,"Cursor ab",
0x4e,"Cursor rechts",
0x4d,"Cursor links",
0x5a,"Num Lock",
0x5b,"Scroll Lock",
0x5d,"Print Screen",
0x3d,"7/Home",
0x3e,"8/Cursor auf",
0x3f,"9/Seite auf",
0x2d,"4/Cursor links",
0x2e,"5",
0x2f,"6/Cursor rechts",
0x1d,"1/End",
0x1e,"2/Cursor ab",
0x1f,"3/Seite ab",
0x0f,"0/Insert",
0x3c,"./Del",
0x4a,"Ziffernblock: +",
0x5e,"Ziffernblock: -",
0x5c,"Ziffernblock: /",
0x0e,NULL,
0x1c,NULL,
0x2c,NULL,
0x3b,NULL,
-1,NULL
};
/* Sondertastenname ermitteln */
BOOL GetRawName(select)
UBYTE select;
{
REGISTER WORD i;
for(i=0;RawName[i].Select!=-1;i++)
{
if(RawName[i].Select==select)
{
if(RawName[i].Name!=NULL) sprintf(&Name,"<%s>",RawName[i].Name);
return(TRUE);
}
}
return(FALSE);
}
/* Tastenname ermitteln */
UBYTE *GetName(select)
UBYTE select;
{
UBYTE byte;
UBYTE anz;
BOOL res;
strcpy(&Name,"");
res=GetRawName(select);
if((res==FALSE)&&(select>=0x00)&&(select<0x40))
{
ie.ie_Code=select;
anz=RawKeyConvert(&ie,&byte,1L,NULL);
if(anz==1) sprintf(&Name,"<%c>",byte);
}
return(&Name);
}
/* Gadget-Texte auf Länge prüfen */
VOID CheckST()
{
REGISTER UBYTE i,j,k;
for(i=0;i<=7;i++)
{
k=strlen(&ST[i]);
for(j=k;j<38;j++) strcat(&ST[i]," ");
}
}
/* Hex-Zeichen in Zahl wandeln */
UBYTE GetHex(chr)
UBYTE chr;
{
if((chr>='0')&&(chr<='9')) return(chr-48);
return(chr-55);
}
/* Editorzeile anzeigen */
VOID PrintS(rp,select,value,upValue,phase,color)
struct RastPort *rp;
UBYTE select;
UBYTE value;
UBYTE upValue;
UBYTE phase;
UBYTE color;
{
REGISTER WORD i;
UBYTE str[50];
if(color==1) SelectStdFPen(rp); else SetAPen(rp,3);
switch(phase)
{
case 0:
sprintf(&str,"$%02lx -> $%02lx ($%02lx) %s",select,value,upValue,GetName(select));
break;
case 1:
sprintf(&str,"$%02lx -> $%lx- ($--) %s",select,value,GetName(select));
break;
case 2:
sprintf(&str,"COPY [$%02lx -> $%02lx ($%02lx) %s]",select,value,upValue,GetName(select));
break;
case 3:
sprintf(&str,"SWAP [$%02lx -> $%02lx ($%02lx) %s]",select,value,upValue,GetName(select));
break;
}
for(i=strlen(&str);i<45;i++) strcat(&str," ");
WriteText(rp,10,32,&str);
}
/* Editor-Reset */
VOID ResetEditor(win,pos,refresh)
struct Window *win;
UBYTE pos;
BOOL refresh;
{
REGISTER WORD i,j;
for(i=pos,j=0;i<=(pos+7);i++,j++)
{
sprintf(&ST[j],
"$%02lx -> $%02lx ($%02lx) %s",
i,
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[i],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[i+BIT7],
GetName(i));
}
CheckST();
if(refresh==TRUE) RefreshGadgets(&Select_Gadget[0],win,NULL);
}
/* ASCII-Zeile schreiben */
VOID AWrite(fh,tex)
struct FileHandle *fh;
UBYTE *tex;
{
Write(fh,tex,strlen(tex));
}
UBYTE *Logo[]=
{
"***********************************************\n",
"**** ****\n",
"**** ATKeyboard 3.0 Translator File ****\n"
};
/* Translator-Datei schreiben */
VOID WriteTranslator(fh)
struct FileHandle *fh;
{
REGISTER WORD i;
UBYTE buf[64];
AWrite(fh,Logo[0]);
AWrite(fh,Logo[1]);
AWrite(fh,Logo[2]);
AWrite(fh,Logo[1]);
AWrite(fh,Logo[0]);
AWrite(fh,"\n\nPC <- Amiga <- Taste\n-----------------------\n");
for(i=0;i<=0x7f;i++)
{
sprintf(&buf,"$%02lx <- $%02lx <- %s\n",
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[i],
i,GetName(i));
AWrite(fh,&buf);
}
}
/* Zeile lesen */
BOOL ReadLine(fh,tex)
struct FileHandle *fh;
UBYTE *tex;
{
REGISTER WORD i,j,anz;
UBYTE byte;
anz=0;
for(i=0;i<79;i++)
{
j=Read(fh,&byte,1L);
if(j==0)
{
tex[anz]=0x00;
return(FALSE);
}
switch(byte)
{
case 13:
case 10:
tex[anz]=0x00;
return(TRUE);
break;
default:
tex[anz]=byte;
anz++;
break;
}
}
tex[79]=0x00;
return(TRUE);
}
/* Translator-Datei lesen */
VOID ReadTranslator(win,fh,pos,select)
struct Window *win;
struct FileHandle *fh;
UBYTE pos;
UBYTE select;
{
REGISTER WORD a,b,zeile;
REGISTER UBYTE anz;
REGISTER BOOL okay,res;
UBYTE byte;
UBYTE buf[80];
UBYTE TBuffer[128];
UBYTE *Titel;
Titel=win->Title;
SetWindowTitles(win,"Lade Translator-Datei...",-1L);
okay=FALSE;
anz=0;
zeile=0;
while(okay==FALSE)
{
res=ReadLine(fh,&buf);
zeile++;
if(res==TRUE)
{
if(buf[0]=='$')
{
buf[1]=toupper(buf[1]);
buf[2]=toupper(buf[2]);
a=b=-1L;
if( ((buf[1]>='0')&&(buf[1]<='9')) || ((buf[1]>='A')&&(buf[1]<='F')) ) a=GetHex(buf[1]);
if( ((buf[2]>='0')&&(buf[2]<='9')) || ((buf[2]>='A')&&(buf[2]<='F')) ) b=GetHex(buf[2]);
if((a==-1L)||(b==-1L))
{
if(a==-1L) a=1; else a=2;
sprintf(&buf,"%ld, %ld. Zeichen.",zeile,a);
Requester("Formatfehler in Zeile",&buf,"Okay",NULL);
okay=TRUE;
}
TBuffer[anz]=(a*16)+b;
anz++;
if(anz==128) okay=TRUE;
}
}
else
{
okay=TRUE;
}
}
if(anz==128)
{
for(a=0;a<=127;a++)
{
if(TBuffer[a]>=BIT7) TBuffer[a]-=BIT7;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[a]=TBuffer[a];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[a+BIT7]=TBuffer[a]+BIT7;
}
ResetEditor(win,pos,TRUE);
PrintS(win->RPort,0,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[select+BIT7],0,1);
}
else
{
sprintf(&buf,"%ld statt 128 Zeichen.",anz);
Requester("Die Translator-Datei enthält nur",&buf,"Okay",NULL);
}
SetWindowTitles(win,Titel,-1L);
}
/* Tasten-Test */
VOID TastenTest()
{
register struct Window *win;
register struct IntuiMessage *msg;
REGISTER ULONG Class;
REGISTER UWORD Code,Qualifier,i;
REGISTER BOOL ende;
ende=FALSE;
win=CreateStdWindow("Testen-Test -> Bitte Eingaben machen <-",
75,5,450,11,
CLOSEWINDOW|RAWKEY,
WINDOWDEPTH|WINDOWDRAG|WINDOWCLOSE|ACTIVATE);
if(win!=NULL)
{
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
Code=msg->Code;
Qualifier=msg->Qualifier;
ReplyMsg(msg);
switch(Class)
{
case RAWKEY:
for(i=0;i<256;i++) TastenTabelle[i]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[i];
Taste(Code,Qualifier);
break;
case CLOSEWINDOW:
ende=TRUE;
break;
}
}
DeleteStdWindow(win);
}
}
/* Editor-Hauptprogramm */
VOID TMEditor()
{
register struct Gadget *Gadget;
register struct Window *win;
register struct IntuiMessage *msg;
register struct RastPort *rp;
register struct FileHandle *fh;
REGISTER UBYTE *k;
REGISTER ULONG Class;
REGISTER UWORD Code,ItemNum,MenuNum,SubItemNum;
REGISTER WORD i,j,id,pos;
UBYTE Select,Phase,STNum,Value,UndoChar,copy;
BOOL ende,refresh,changed;
BackupKeys=AllocMem(256,MEMF_CLEAR|MEMF_PUBLIC);
if(BackupKeys==NULL) return;
CopyMem(&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,BackupKeys,256);
Select=0;
Phase=0;
STNum=0;
Value=0;
copy=0;
changed=FALSE;
UndoChar=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[0];
PInfo.VertPot=0;
pos=0;
ResetEditor(NULL,0,FALSE);
win=OpenWindow(&TMWindow);
if(win!=NULL)
{
rp=win->RPort;
SetFont(rp,GetOpalFont());
DrawPTextBorder(win,10,12,80,10,"Test");
DrawPTextBorder(win,150,12,80,10,"Kopie");
DrawPTextBorder(win,240,12,80,10,"Tausch");
DrawPBorder(win,9,39,341,81);
DrawNBorder(win,364,39,69,81);
SetMenuStrip(win,&TDatei_Menu);
PrintS(rp,0,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[0],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[BIT7],
0,1);
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
Code=msg->Code;
Gadget=msg->IAddress;
ReplyMsg(msg);
switch(Class)
{
case VANILLAKEY:
changed=TRUE;
Code=toupper(Code);
refresh=FALSE;
if(((Code>='0')&&(Code<='9')) || ((Code>='A')&&(Code<='F')))
{
switch(Phase)
{
case 0:
Value=GetHex(Code);
PrintS(rp,Select,Value,0,1,2);
Phase=1;
break;
case 1:
Value=(Value*16)+GetHex(Code);
if(Value>=BIT7) Value-=BIT7;
PrintS(rp,Select,Value,Value+BIT7,0,2);
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select]=Value;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7]=Value+BIT7;
Phase=0;
refresh=TRUE;
break;
}
}
else if((Code==13)&&(Phase==1))
{
PrintS(rp,Select,Value,Value+BIT7,0,2);
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select]=Value;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7]=Value+BIT7;
Phase=0;
refresh=TRUE;
}
else if(Code==27)
{
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select]=UndoChar;
Phase=0;
PrintS(rp,Select,UndoChar,UndoChar+BIT7,0,1);
Value=UndoChar;
refresh=TRUE;
}
if(refresh==TRUE)
{
sprintf(&ST[STNum],"$%02lx -> $%02lx ($%02lx) %s",Select,Value,Value+BIT7,GetName(Select));
CheckST();
RefreshGadgets(&Select_Gadget[STNum],win,NULL);
}
break;
case MENUPICK:
MenuNum=MENUNUM(Code);
ItemNum=ITEMNUM(Code);
SubItemNum=SUBNUM(Code);
switch(MenuNum)
{
case MENU_DATEI:
switch(ItemNum)
{
case ITEM_SICHERN:
switch(SubItemNum)
{
case SUBITEM_CODETABLE:
if(FileRequester!=NULL)
{
k=FileReq("CodeTable-Datei sichern:","#?.codetable");
}
else
{
k=StringAbfrage(FALSE,"Name der CodeTable-Datei:","");
}
if((strcmp(k,"")))
{
fh=Open(k,MODE_NEWFILE);
if(fh!=NULL)
{
Write(fh,&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,256);
Close(fh);
}
else
{
Requester("Konnte die CodeTable-Datei","nicht erstellen.","Okay",NULL);
}
}
break;
case SUBITEM_TRANSLATOR:
if(FileRequester!=NULL)
{
k=FileReq("Translator-Datei sichern:","#?.translator");
}
else
{
k=StringAbfrage(FALSE,"Name der Translator-Datei:","");
}
if((strcmp(k,"")))
{
fh=Open(k,MODE_NEWFILE);
if(fh!=NULL)
{
WriteTranslator(fh);
Close(fh);
}
else
{
Requester("Konnte die Translator-Datei","nicht erstellen.","Okay",NULL);
}
}
break;
}
break;
case ITEM_LADEN:
switch(SubItemNum)
{
case SUBITEM_CODETABLE:
if(FileRequester!=NULL)
{
k=FileReq("CodeTable-Datei laden:","#?.codetable");
}
else
{
k=StringAbfrage(FALSE,"Name der CodeTable-Datei:","");
}
if((strcmp(k,"")))
{
fh=Open(k,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,256);
changed=TRUE;
Close(fh);
}
else
{
Requester("Konnte die CodeTable-Datei","nicht laden.","Okay",NULL);
}
}
break;
case SUBITEM_TRANSLATOR:
if(FileRequester!=NULL)
{
k=FileReq("Translator-Datei laden:","#?.translator");
}
else
{
k=StringAbfrage(FALSE,"Name der Translator-Datei:","");
}
if((strcmp(k,"")))
{
fh=Open(k,MODE_OLDFILE);
if(fh!=NULL)
{
ReadTranslator(win,fh,pos,Select);
changed=TRUE;
Close(fh);
}
else
{
Requester("Konnte die Translator-Datei","nicht laden.","Okay",NULL);
}
}
break;
}
break;
case ITEM_ENDE:
ende=TRUE;
break;
}
break;
case MENU_BEARBEITEN:
switch(ItemNum)
{
case ITEM_UNDO:
CopyMem(BackupKeys,&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,256);
ResetEditor(win,pos,TRUE);
PrintS(rp,0,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],0,1);
break;
case ITEM_KOPIEREN:
copy=1; changed=TRUE;
PrintS(rp,Select,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],2,1);
break;
case ITEM_TAUSCHEN:
copy=2; changed=TRUE;
PrintS(rp,Select,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],3,1);
break;
}
break;
}
break;
case GADGETUP:
id=Gadget->GadgetID;
switch(id)
{
case 500:
pos=PInfo.VertPot/512;
if(pos>=120) pos=120;
ResetEditor(win,pos,TRUE);
break;
case 1000:
ClearMenuStrip(win);
TastenTest();
SetMenuStrip(win,&TDatei_Menu);
break;
case 2000:
if(copy==1) { j=0; copy=0; } else { j=2; copy=1; }
PrintS(rp,Select,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],j,1);
break;
case 3000:
if(copy==2) { j=0; copy=0; } else { j=3; copy=2; }
PrintS(rp,Select,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],j,1);
break;
default:
if((id>=0)&&(id<=7))
{
switch(copy)
{
case 1:
copy=0;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[pos+id] =KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[pos+id+BIT7]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7];
ResetEditor(win,pos,TRUE);
break;
case 2:
j=pos+id+BIT7;
i=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[pos+id];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[j];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[pos+id]=i;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[j]=i+BIT7;
copy=0;
ResetEditor(win,pos,TRUE);
break;
default:
Select=pos+id;
Phase=0;
STNum=id;
break;
}
UndoChar=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
PrintS(rp,Select,UndoChar,UndoChar+BIT7,0,1);
}
}
break;
case CLOSEWINDOW:
if(changed==TRUE)
{
ende=UsePrefs();
if(ende==FALSE)
{
CopyMem(BackupKeys,&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,256);
}
}
ende=TRUE;
break;
}
}
ClearMenuStrip(win);
CloseWindow(win);
for(i=0;i<256;i++) TastenTabelle[i]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[i];
}
FreeMem(BackupKeys,256);
}
/* Modusname ändern/Modus (de)aktivieren */
VOID TMOnOff()
{
REGISTER ULONG Class;
REGISTER BOOL bool;
REGISTER WORD i,j;
UBYTE *Name[8];
struct Gadget *OnOff_Gadget[7];
register struct Gadget *g;
register struct Window *win;
register struct IntuiMessage *msg;
win=CreateStdWindow("ATKeyboard - Tastaturmodus (de)aktivieren",
75,20,450,140,CLOSEWINDOW,
WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|ACTIVATE);
if(win!=NULL)
{
SetFont(win->RPort,GetOpalFont());
for(i=29,j=0;i<=119;i+=15,j++)
{
if(KeyCodes->KeyTab[j+1].Valid)
{
OnOff_Gadget[j]=CreateSToggleGadget(win,10,i,100,12,"Aktiv",j);
}
else
{
OnOff_Gadget[j]=CreateNToggleGadget(win,10,i,100,12,"Aktiv",j);
}
}
for(i=15,j=0;i<=120;i+=15,j++)
{
Name[j]=CreateStringGadget(win,130,i,290,10,&KeyCodes->KeyTab[j].Name[2],30,100);
}
bool=FALSE;
while(bool==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
g=msg->IAddress;
switch(Class)
{
case CLOSEWINDOW:
bool=TRUE;
break;
}
ReplyMsg(msg);
}
bool=UsePrefs();
DeleteStdWindow(win);
if(bool==TRUE)
{
for(i=0;i<=6;i++)
{
if(OnOff_Gadget[i]->Flags & SELECTED)
{
TM_Item[i+1].Flags |= ITEMENABLED;
KeyCodes->KeyTab[i+1].Valid=1;
}
else
{
TM_Item[i+1].Flags &= xITEMENABLED;
KeyCodes->KeyTab[i+1].Valid=0;
}
}
for(i=0;i<=7;i++)
{
strcpy(&KeyCodes->KeyTab[i].Name," ");
strcpy(&KeyCodes->KeyTab[i].Name[2],Name[i]);
}
NeuerModus(Einstellungen.Tastaturmodus,FALSE);
}
}
}